package com.ruoyi.system.netty;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class WsTcpApplicationRunner implements ApplicationRunner {

    @Autowired
    CustomHandler customHandler;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.info("Tcp服务启动监听");
        new Thread(() -> {
            try {
                NettyTcpServer server = new NettyTcpServer(25106, customHandler);
                server.run();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();
    }
}
